mvp struct.

chengzhenyu преди 8 години
родител
ревизия
ba192ce761

+ 23 - 0
app/src/main/java/ai/pai/lensman/base/BasePresenter.java

@@ -0,0 +1,23 @@
1
+/*
2
+ * Copyright 2016, The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *      http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package ai.pai.lensman.base;
18
+
19
+public interface BasePresenter {
20
+
21
+    void start();
22
+
23
+}

+ 23 - 0
app/src/main/java/ai/pai/lensman/base/BaseView.java

@@ -0,0 +1,23 @@
1
+/*
2
+ * Copyright 2016, The Android Open Source Project
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *      http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package ai.pai.lensman.base;
18
+
19
+public interface BaseView<T> {
20
+
21
+    void setPresenter(T presenter);
22
+
23
+}

+ 4 - 0
app/src/main/java/ai/pai/lensman/login/LoginActivity.java

@@ -59,4 +59,8 @@ public class LoginActivity extends BaseActivity implements LoginContract.View{
59 59
         finish();
60 60
     }
61 61
 
62
+    @Override
63
+    public void setPresenter(LoginContract.Presenter presenter) {
64
+
65
+    }
62 66
 }

+ 5 - 5
app/src/main/java/ai/pai/lensman/login/LoginContract.java

@@ -1,11 +1,11 @@
1 1
 package ai.pai.lensman.login;
2 2
 
3
-/**
4
- * Created by chengzhenyu on 2016/8/11.
5
- */
3
+import ai.pai.lensman.base.BasePresenter;
4
+import ai.pai.lensman.base.BaseView;
5
+
6 6
 public class LoginContract {
7 7
 
8
-    interface View{
8
+    interface View extends BaseView<Presenter>{
9 9
         void showLoginHint(String hint);
10 10
         void showProgressView();
11 11
         void hideProgressView();
@@ -13,7 +13,7 @@ public class LoginContract {
13 13
 
14 14
     }
15 15
 
16
-    interface Presenter{
16
+    interface Presenter extends BasePresenter{
17 17
         void login(String userName,String pwd);
18 18
     }
19 19
 

+ 5 - 0
app/src/main/java/ai/pai/lensman/login/LoginPresenter.java

@@ -17,4 +17,9 @@ public class LoginPresenter implements LoginContract.Presenter {
17 17
 
18 18
     }
19 19
 
20
+    @Override
21
+    public void start() {
22
+
23
+    }
24
+
20 25
 }

+ 13 - 8
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -5,7 +5,6 @@ import android.content.Intent;
5 5
 import android.os.Bundle;
6 6
 import android.support.v7.widget.LinearLayoutManager;
7 7
 import android.support.v7.widget.RecyclerView;
8
-import android.view.View;
9 8
 import android.widget.TextView;
10 9
 
11 10
 import ai.pai.lensman.R;
@@ -17,14 +16,15 @@ import butterknife.BindView;
17 16
 import butterknife.ButterKnife;
18 17
 import butterknife.OnClick;
19 18
 
20
-public class SessionActivity extends BaseActivity implements SessionContract.SessionView {
19
+public class SessionActivity extends BaseActivity implements SessionContract.View {
21 20
 
22
-    @BindView(R.id.icon_no_data) View noPhotoLayout;
21
+    @BindView(R.id.icon_no_data)
22
+    android.view.View noPhotoLayout;
23 23
     @BindView(R.id.title_bar_middle_txt) TextView titleTextView;
24 24
     @BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView;
25 25
     private PhotoRecyclerAdapter adapter;
26 26
     private  SessionBean sessionBean;
27
-    private SessionContract.SessionPresenter presenter;
27
+    private SessionContract.Presenter presenter;
28 28
 
29 29
     private static final int JOIN_REQUEST_CODE = 3002;
30 30
 
@@ -93,8 +93,8 @@ public class SessionActivity extends BaseActivity implements SessionContract.Ses
93 93
         runOnUiThread(new Runnable() {
94 94
             @Override
95 95
             public void run() {
96
-                noPhotoLayout.setVisibility(View.GONE);
97
-                photosRecyclerView.setVisibility(View.VISIBLE);
96
+                noPhotoLayout.setVisibility(android.view.View.GONE);
97
+                photosRecyclerView.setVisibility(android.view.View.VISIBLE);
98 98
             }
99 99
         });
100 100
     }
@@ -104,8 +104,8 @@ public class SessionActivity extends BaseActivity implements SessionContract.Ses
104 104
         runOnUiThread(new Runnable() {
105 105
             @Override
106 106
             public void run() {
107
-                photosRecyclerView.setVisibility(View.GONE);
108
-                noPhotoLayout.setVisibility(View.VISIBLE);
107
+                photosRecyclerView.setVisibility(android.view.View.GONE);
108
+                noPhotoLayout.setVisibility(android.view.View.VISIBLE);
109 109
             }
110 110
         });
111 111
     }
@@ -120,4 +120,9 @@ public class SessionActivity extends BaseActivity implements SessionContract.Ses
120 120
         }
121 121
 
122 122
     }
123
+
124
+    @Override
125
+    public void setPresenter(SessionContract.Presenter presenter) {
126
+
127
+    }
123 128
 }

+ 4 - 3
app/src/main/java/ai/pai/lensman/session/SessionContract.java

@@ -1,5 +1,7 @@
1 1
 package ai.pai.lensman.session;
2 2
 
3
+import ai.pai.lensman.base.BasePresenter;
4
+import ai.pai.lensman.base.BaseView;
3 5
 import ai.pai.lensman.bean.PhotoBean;
4 6
 
5 7
 /**
@@ -7,14 +9,13 @@ import ai.pai.lensman.bean.PhotoBean;
7 9
  */
8 10
 public class SessionContract {
9 11
 
10
-    interface SessionView{
12
+    interface View extends BaseView<Presenter>{
11 13
         void addNewPhoto(PhotoBean bean);
12 14
         void showPhotoRecyclerView();
13 15
         void showEmptyView();
14 16
     }
15 17
 
16
-    interface SessionPresenter{
17
-        void start();
18
+    interface Presenter extends BasePresenter{
18 19
         void stop();
19 20
     }
20 21
 }

+ 3 - 3
app/src/main/java/ai/pai/lensman/session/SessionPresenterImpl.java

@@ -6,14 +6,14 @@ import java.util.ArrayList;
6 6
 
7 7
 import ai.pai.lensman.bean.PhotoBean;
8 8
 
9
-public class SessionPresenterImpl implements SessionContract.SessionPresenter ,SessionInteractor.SessionListener{
9
+public class SessionPresenterImpl implements SessionContract.Presenter,SessionInteractor.SessionListener{
10 10
 
11 11
     private Context context;
12 12
     private SessionInteractor interactor;
13 13
     private ArrayList<PhotoBean> photoList;
14
-    private SessionContract.SessionView sessionView;
14
+    private SessionContract.View sessionView;
15 15
 
16
-    public SessionPresenterImpl(Context context,String sessionId, SessionContract.SessionView view){
16
+    public SessionPresenterImpl(Context context,String sessionId, SessionContract.View view){
17 17
         this.context = context;
18 18
         this.sessionView = view;
19 19
         photoList = new ArrayList<>();

+ 12 - 8
app/src/main/java/ai/pai/lensman/upload/UploadActivity.java

@@ -5,7 +5,6 @@ import android.os.Bundle;
5 5
 import android.support.v7.widget.GridLayoutManager;
6 6
 import android.support.v7.widget.LinearLayoutManager;
7 7
 import android.support.v7.widget.RecyclerView;
8
-import android.view.View;
9 8
 import android.widget.ImageView;
10 9
 import android.widget.TextView;
11 10
 
@@ -19,14 +18,15 @@ import butterknife.BindView;
19 18
 import butterknife.ButterKnife;
20 19
 import butterknife.OnClick;
21 20
 
22
-public class UploadActivity extends BaseActivity implements UploadContract.UploadView{
21
+public class UploadActivity extends BaseActivity implements UploadContract.View {
23 22
 
24 23
     @BindView(R.id.tv_bt_status) TextView btStatusTextView;
25 24
     @BindView(R.id.iv_bt_status) ImageView btStatusImageView;
26
-    @BindView(R.id.icon_no_data) View noDataLayout;
25
+    @BindView(R.id.icon_no_data)
26
+    android.view.View noDataLayout;
27 27
     @BindView(R.id.recycler_view_sessions) RecyclerView sessionsRecyclerView;
28 28
     private SessionRecyclerAdapter adapter;
29
-    private UploadContract.UploadPresenter presenter;
29
+    private UploadContract.Presenter presenter;
30 30
 
31 31
     @Override
32 32
     protected void onCreate(Bundle savedInstanceState) {
@@ -102,8 +102,8 @@ public class UploadActivity extends BaseActivity implements UploadContract.Uploa
102 102
         runOnUiThread(new Runnable() {
103 103
             @Override
104 104
             public void run() {
105
-                sessionsRecyclerView.setVisibility(View.GONE);
106
-                noDataLayout.setVisibility(View.VISIBLE);
105
+                sessionsRecyclerView.setVisibility(android.view.View.GONE);
106
+                noDataLayout.setVisibility(android.view.View.VISIBLE);
107 107
             }
108 108
         });
109 109
 
@@ -114,8 +114,8 @@ public class UploadActivity extends BaseActivity implements UploadContract.Uploa
114 114
         runOnUiThread(new Runnable() {
115 115
             @Override
116 116
             public void run() {
117
-                noDataLayout.setVisibility(View.GONE);
118
-                sessionsRecyclerView.setVisibility(View.VISIBLE);
117
+                noDataLayout.setVisibility(android.view.View.GONE);
118
+                sessionsRecyclerView.setVisibility(android.view.View.VISIBLE);
119 119
             }
120 120
         });
121 121
 
@@ -137,4 +137,8 @@ public class UploadActivity extends BaseActivity implements UploadContract.Uploa
137 137
         });
138 138
     }
139 139
 
140
+    @Override
141
+    public void setPresenter(UploadContract.Presenter presenter) {
142
+
143
+    }
140 144
 }

+ 4 - 3
app/src/main/java/ai/pai/lensman/upload/UploadContract.java

@@ -2,6 +2,8 @@ package ai.pai.lensman.upload;
2 2
 
3 3
 import java.util.ArrayList;
4 4
 
5
+import ai.pai.lensman.base.BasePresenter;
6
+import ai.pai.lensman.base.BaseView;
5 7
 import ai.pai.lensman.bean.SessionBean;
6 8
 
7 9
 /**
@@ -9,7 +11,7 @@ import ai.pai.lensman.bean.SessionBean;
9 11
  */
10 12
 public class UploadContract {
11 13
 
12
-    interface UploadView{
14
+    interface View extends BaseView<Presenter> {
13 15
 
14 16
         void addNewSessionView(SessionBean bean);
15 17
         void showBTDisconnectedView();
@@ -21,10 +23,9 @@ public class UploadContract {
21 23
 
22 24
     }
23 25
 
24
-    interface UploadPresenter{
26
+    interface Presenter extends BasePresenter{
25 27
 
26 28
         void checkBTStatus();
27
-        void start();
28 29
         void stop();
29 30
         void jumpToBriefs();
30 31
         void jumpToNewSession();

+ 3 - 3
app/src/main/java/ai/pai/lensman/upload/UploadPresenterImpl.java

@@ -8,14 +8,14 @@ import java.util.ArrayList;
8 8
 import ai.pai.lensman.bean.SessionBean;
9 9
 import ai.pai.lensman.session.SessionActivity;
10 10
 
11
-public class UploadPresenterImpl implements UploadContract.UploadPresenter {
11
+public class UploadPresenterImpl implements UploadContract.Presenter {
12 12
 
13 13
     private Activity activity;
14
-    private UploadContract.UploadView uploadView;
14
+    private UploadContract.View uploadView;
15 15
     private ArrayList<SessionBean> sessionList;
16 16
 
17 17
     private int seq = 0;
18
-    public UploadPresenterImpl(Activity activity,UploadContract.UploadView view){
18
+    public UploadPresenterImpl(Activity activity,UploadContract.View view){
19 19
         this.activity = activity;
20 20
         this.uploadView = view;
21 21
         sessionList = new ArrayList<>();

+ 104 - 97
app/src/main/res/layout/activity_login.xml

@@ -1,110 +1,117 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
-    android:layout_width="match_parent"
4
-    android:layout_height="match_parent"
5 3
     xmlns:progress="http://schemas.android.com/apk/res-auto"
6
-    android:background="@color/login_bg_blue">
7
-
8
-    <ImageView
9
-        android:id="@+id/iv_login_logo"
10
-        android:layout_width="128dp"
11
-        android:layout_height="128dp"
12
-        android:layout_centerHorizontal="true"
13
-        android:layout_marginTop="32dp"
14
-        android:src="@drawable/logo" />
15
-
16
-    <LinearLayout
17
-        android:id="@+id/layout_login_edit"
18
-        android:layout_width="290dp"
19
-        android:layout_height="96dp"
20
-        android:layout_below="@id/iv_login_logo"
21
-        android:layout_centerHorizontal="true"
22
-        android:layout_marginTop="16dp"
23
-        android:background="@drawable/login_rounded_rect_bg"
24
-        android:orientation="vertical"
25
-        android:paddingLeft="10dp"
26
-        android:paddingRight="10dp">
27
-
28
-        <RelativeLayout
29
-            android:layout_width="match_parent"
30
-            android:layout_height="0dp"
31
-            android:layout_weight="1">
32
-
33
-            <ImageView
34
-                android:id="@+id/iv_login_user_avatar"
35
-                android:layout_width="28dp"
36
-                android:layout_height="28dp"
37
-                android:layout_centerVertical="true"
38
-                android:src="@drawable/user_avatar" />
39
-
40
-            <EditText
41
-                android:id="@+id/et_login_user_name"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="match_parent">
6
+
7
+    <RelativeLayout
8
+        android:layout_width="match_parent"
9
+        android:layout_height="match_parent"
10
+        android:background="@color/login_bg_blue">
11
+
12
+        <ImageView
13
+            android:id="@+id/iv_login_logo"
14
+            android:layout_width="128dp"
15
+            android:layout_height="128dp"
16
+            android:layout_centerHorizontal="true"
17
+            android:layout_marginTop="32dp"
18
+            android:src="@drawable/logo" />
19
+
20
+        <LinearLayout
21
+            android:id="@+id/layout_login_edit"
22
+            android:layout_width="290dp"
23
+            android:layout_height="96dp"
24
+            android:layout_below="@id/iv_login_logo"
25
+            android:layout_centerHorizontal="true"
26
+            android:layout_marginTop="16dp"
27
+            android:background="@drawable/login_rounded_rect_bg"
28
+            android:orientation="vertical"
29
+            android:paddingLeft="10dp"
30
+            android:paddingRight="10dp">
31
+
32
+            <RelativeLayout
42 33
                 android:layout_width="match_parent"
43
-                android:layout_height="match_parent"
44
-                android:layout_marginLeft="12dp"
45
-                android:layout_toRightOf="@+id/iv_login_user_avatar"
46
-                android:background="@color/white"
47
-                android:gravity="center_vertical"
48
-                android:hint="@string/account_name"
49
-                android:textColor="@color/dark_grey"
50
-                android:textColorHint="@color/text_hint_grey_color"
51
-                android:textSize="16sp" />
52
-
53
-
54
-        </RelativeLayout>
55
-
56
-        <View
57
-            android:layout_width="match_parent"
58
-            android:layout_height="1px"
59
-            android:background="@color/line_bg"/>
60
-        <RelativeLayout
61
-            android:layout_width="match_parent"
62
-            android:layout_height="0dp"
63
-            android:layout_weight="1">
64
-
65
-            <ImageView
66
-                android:id="@+id/iv_login_pwd"
67
-                android:layout_width="28dp"
68
-                android:layout_height="28dp"
69
-                android:layout_centerVertical="true"
70
-                android:src="@drawable/password" />
71
-
72
-            <EditText
73
-                android:id="@+id/et_login_pwd"
34
+                android:layout_height="0dp"
35
+                android:layout_weight="1">
36
+
37
+                <ImageView
38
+                    android:id="@+id/iv_login_user_avatar"
39
+                    android:layout_width="28dp"
40
+                    android:layout_height="28dp"
41
+                    android:layout_centerVertical="true"
42
+                    android:src="@drawable/user_avatar" />
43
+
44
+                <EditText
45
+                    android:id="@+id/et_login_user_name"
46
+                    android:layout_width="match_parent"
47
+                    android:layout_height="match_parent"
48
+                    android:layout_marginLeft="12dp"
49
+                    android:layout_toRightOf="@+id/iv_login_user_avatar"
50
+                    android:background="@color/white"
51
+                    android:gravity="center_vertical"
52
+                    android:hint="@string/account_name"
53
+                    android:textColor="@color/dark_grey"
54
+                    android:textColorHint="@color/text_hint_grey_color"
55
+                    android:textSize="16sp" />
56
+
57
+
58
+            </RelativeLayout>
59
+
60
+            <View
61
+                android:layout_width="match_parent"
62
+                android:layout_height="1px"
63
+                android:background="@color/line_bg" />
64
+
65
+            <RelativeLayout
74 66
                 android:layout_width="match_parent"
75
-                android:layout_height="match_parent"
76
-                android:layout_marginLeft="12dp"
77
-                android:layout_toRightOf="@+id/iv_login_pwd"
78
-                android:background="@color/white"
79
-                android:gravity="center_vertical"
80
-                android:hint="@string/password"
81
-                android:inputType="textPassword"
82
-                android:textColor="@color/dark_grey"
83
-                android:textColorHint="@color/text_hint_grey_color"
84
-                android:textSize="16sp" />
85
-
86
-        </RelativeLayout>
87
-    </LinearLayout>
88
-
89
-    <Button
90
-        android:id="@+id/btn_login"
91
-        android:layout_width="290dp"
92
-        android:layout_height="48dp"
93
-        android:layout_below="@id/layout_login_edit"
94
-        android:layout_centerHorizontal="true"
95
-        android:layout_marginTop="15dp"
96
-        android:background="@drawable/login_btn_rounded_rect_bg"
97
-        android:gravity="center"
98
-        android:text="@string/login"
99
-        android:textColor="@color/white"
100
-        android:textSize="18sp" />
67
+                android:layout_height="0dp"
68
+                android:layout_weight="1">
69
+
70
+                <ImageView
71
+                    android:id="@+id/iv_login_pwd"
72
+                    android:layout_width="28dp"
73
+                    android:layout_height="28dp"
74
+                    android:layout_centerVertical="true"
75
+                    android:src="@drawable/password" />
76
+
77
+                <EditText
78
+                    android:id="@+id/et_login_pwd"
79
+                    android:layout_width="match_parent"
80
+                    android:layout_height="match_parent"
81
+                    android:layout_marginLeft="12dp"
82
+                    android:layout_toRightOf="@+id/iv_login_pwd"
83
+                    android:background="@color/white"
84
+                    android:gravity="center_vertical"
85
+                    android:hint="@string/password"
86
+                    android:inputType="textPassword"
87
+                    android:textColor="@color/dark_grey"
88
+                    android:textColorHint="@color/text_hint_grey_color"
89
+                    android:textSize="16sp" />
90
+
91
+            </RelativeLayout>
92
+        </LinearLayout>
93
+
94
+        <Button
95
+            android:id="@+id/btn_login"
96
+            android:layout_width="290dp"
97
+            android:layout_height="48dp"
98
+            android:layout_below="@id/layout_login_edit"
99
+            android:layout_centerHorizontal="true"
100
+            android:layout_marginTop="15dp"
101
+            android:background="@drawable/login_btn_rounded_rect_bg"
102
+            android:gravity="center"
103
+            android:text="@string/login"
104
+            android:textColor="@color/white"
105
+            android:textSize="18sp" />
106
+    </RelativeLayout>
101 107
 
102 108
     <com.android.views.progressbar.ProgressWheel
103 109
         android:id="@+id/wheel_wait_http"
104 110
         android:layout_width="80dp"
105 111
         android:layout_height="80dp"
106 112
         android:layout_centerInParent="true"
107
-        progress:text="@string/please_wait"
108
-        android:visibility="gone"/>
113
+        android:visibility="gone"
114
+        progress:textColor="@color/white"
115
+        progress:barColor="@color/colorPrimary"/>
109 116
 
110 117
 </RelativeLayout>